package edu.utd.text.game.controller.commands;

import edu.utd.text.game.controller.Controller;
import edu.utd.text.game.domain.areas.Direction;
import edu.utd.text.game.domain.exceptions.DeadEndEncounteredException;
import edu.utd.text.game.domain.exceptions.InvalidDirectionException;
import edu.utd.text.game.domain.player.Player;

public class MovementCommand implements GameCommand {
	Direction directionToMove;
	
	public MovementCommand(Direction aDirection) {
		directionToMove = aDirection;
	}
	
	public Direction getDirectionToMove() {
		return directionToMove;
	}
	
	public void setDirectionToMove(Direction aDirection) {
		directionToMove = aDirection;
	}
	
	public String execute() {
		try {
			Controller controller = Controller.INSTANCE;
			Player player = controller.getPlayer();
			player.moveDirection(directionToMove);
			return player.getCurrentRoom().getDescription();
		} catch (DeadEndEncounteredException deex) {
			return "That way is a dead end.";
		} catch (InvalidDirectionException idx) {
			return "Can't go that way.";
		}
	}
}
